var dnow = new Date();tnow = dnow.getTime();
var Mall = MFP = KISSY.app("MFP");
document.domain = (function (b) { var a = location.hostname.split("."); return a.splice((a.length - b) > 0 ? a.length - b : 0, b).join(".") })(2);
MFP.add("category",
	function (i) {
		var d = KISSY, e = d.DOM, n = d.Event, m = document, f = "selected", a = "hidden", j = "DIV", o = "mouseenter", b = "mouseleave", h = "click",
		c = { hideDelay: 0.2, view: null, subViews: null, triggers: null, dataUrl: null };
		function g(p, r) { var q = this; if (!(q instanceof g)) { return new g(p, r) } q.container = d.get(p); q.config = d.merge(c, r || {}); q.config.viewer = d.get(r.view); q.triggers = e.query(r.triggers, q.container); q._init() }
	  function k(p, r) { for (var q = 0; q < p.length; q = q + 1) { if (p[q] === r) { return q } } return -1 }
	  var l = {
	        _msxmls: ["Microsoft.XMLHTTP", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP"],
	        init: function (p, q) { this.timer_timeout = null; this.timer_state_watch = null; this.url = p; this.obj = {}; this.createXhrObject(); this.send(); this.timeout = 100; this.success = q; this.fail = function () { }; this.abort = function () { } },
	        createXhrObject: function () { var r, p; try { this.obj = new XMLHttpRequest() } catch (q) { for (p = 0; p < this._msxmls.length; ++p) { try { this.obj = new ActiveXObject(this._msxmls[p]); break } catch (s) { } } } finally { return r } },
	        send: function () { this.obj.open("GET", this.url, true); this.beginStateWatch(); this.obj.send(null) },
	        beginStateWatch: function () { var q = this.obj; var p = this; if (this.timeout) { this.timer_timeout = setTimeout(function () { q.abort(); clearTimeout(p.timer_timeout); p.timer_timeout = null; p.onAbort() }, this.timeout * 1000) } this.timer_state_watch = setInterval((function (r) { return function () { r.handleReadyState() } })(this), 10) },
	        handleReadyState: function () { var p = this.obj; if (p.readyState === 4 && p.status == 200) { if (this.timer_timeout) { clearTimeout(this.timer_timeout); this.timer_timeout = null } clearInterval(this.timer_state_watch); this.timer_state_watch = null; this.onSuccess() } else { if (p.readyState === 4) { this.onFail() } } },
	        onSuccess: function () { this.success(this.obj) },
	        onAbort: function () { this.abort(this.obj) },
	        onFail: function () { this.fail(this.obj) }
		};
		d.mix(g.prototype, {
	        switchTo: function (p) { var r = this, s = r.triggers, q = r.subViews; d.each(s, function (t) { e.removeClass(t, f) }); e.addClass(r.triggers[p], f); d.each(q, function (t) { e.addClass(t, a) }); e.removeClass(q[p], a) },
	        show: function () { var p = this; p.container.style.zIndex = 20; e.removeClass(p.viewer, a) },
	        hide: function () { var p = this, q = p.triggers; p.container.style.zIndex = 15; d.each(q, function (r) { e.removeClass(r, f) }); e.addClass(p.viewer, a) },
	        getViewerData: function (q) { var p = this; var r = (location.hostname.indexOf("xhgo.net") != -1) ? "/Home/ShowCate" : "/Home/ShowCate"; if (!p.config.getting) { l.init(r + "?t=" + tnow, function (s) { p.config.viewer = s.responseText; p._initView(); if ("hidden" == p.status) { return } p.switchTo(p.config.idx); p.show() }) } p.config.getting = true },
	        _init: function () { var q = this, p = q.config; d.each(q.triggers, function (r) { n.on(r, h, function (s) { s.halt(); return false }); n.on(r, o, function (t) { t.halt(); var s = k(q.triggers, r); q.config.idx = s; q.status = "visible"; if (!q.viewer) { if (!q.config.viewer) { q.getViewerData(q.config.dataUrl); return } q._initView() } if (q.showTimer) { clearTimeout(q.showTimer) } q.showTimer = setTimeout(function () { if (!q.hideTimer) { q.switchTo(s); q.show() } }, q.config.hideDelay * 1000); q.hideTimer = clearTimeout(q.hideTimer) }); n.on(r, b, function (s) { q.status = "hidden"; if (q.showTimer) { clearTimeout(q.showTimer) } if (q.hideTimer) { return } q.hideTimer = setTimeout(function () { q.hide(); q.hideTimer = clearTimeout(q.hideTimer) }, q.config.hideDelay * 1000) }) }) },
	        _initView: function () { var q = this, p = q.config; if (!q.viewer) { q.viewer = m.createElement(j); q.viewer.className = "pop-subcategory hidden"; q.viewer.innerHTML = p.viewer; q.container.appendChild(q.viewer); q._initSubView() } },
	        _initSubView: function () { var p = this, q = 0; p.subViews = e.query(p.config.subViews, p.container); d.each(p.subViews, function (u) { var t = e.query("dl.J_HotMenuItem", u), r = e.query("div.J_HotView", u), s; s = new d.Tabs(u, { triggerType: "mouse", triggers: t, panels: r }); n.on(u, o, function () { p.hideTimer = clearTimeout(p.hideTimer); p.selectedSubView = this }); n.on(u, b, function () { p.hideTimer = setTimeout(function () { p.hide(); p.hideTimer = clearTimeout(p.hideTimer) }, p.config.hideDelay * 1000) }) }) }
		});
		i.Category = g
	}
);
(function () {
	var c = KISSY, l = c.DOM, k = c.Event, g = MFP, j = document, e = "selected", h = "click", b = "scrolly", d, f, a = [function () { new g.Category("#J_Category", { view: "#J_SubCategory", subViews: "div.J_SubViewItem", triggers: "li.J_MenuItem", dataUrl: "/Home/ShowCate" }) } ];
  for (d = 0, f = a.length; d < f; ++d) { a[d]() }
})();
